package com.my.geojson.test.simple;

import com.my.geojson.store.PostgisDataStore;
import org.geotools.data.DataStore;
import org.opengis.referencing.FactoryException;

import java.io.IOException;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws IOException, FactoryException {
        DataStore postgisDataStore = PostgisDataStore.getInstance();
        PostgisUtility.setPgDatastore(postgisDataStore);
//        PostgisUtility.importGeojson("D:\\IdeaProjects\\timo-tool\\gis\\gis-geojson\\src\\main\\resources\\static\\geojson\\a.geojson",
//                "sw_line5");
//        PostgisUtility.importShp("D:\\IdeaProjects\\timo-tool\\gis\\gis-geojson\\src\\main\\resources\\static\\shpTest[Point]\\dp_tl.shp", "sw_line4");
//        PostgisUtility.exportShp("map",
//                "D:\\tmp\\gis\\map.shp");
        PostgisUtility.exportGeojson("map",
                "D:\\tmp\\gis\\map.geojson");
//=====================================重构后===========================================================
        //geojson转成fastjson对象
//        File file=new File("D:\\Users\\Administrator\\Documents\\GitHub\\geotools4postgis\\src\\main\\java\\iwuang\\line.geojson");
//        PostgisUtility.initFeature(file);

//        Date date = new Date();
//        Vector vector = new Vector();
//        vector.setVectorid("123456790");
//        vector.setVectorTableName("sw_cesium");
//
//        vector = PostgisUtility.importGeojson("D:\\IdeaProjects\\cloudwalk-customs-gis\\src\\main\\resources\\static\\geojson\\a.geojson",
//                vector);
//        System.out.println(vector.toString());
//        vector = PostgisUtility.importGeojson(file, vector);
        //更新表结构，失败
//        PostgisUtility.temp("sw_cesium", "test");

//        PostgisUtility.getFieldsOfShp("D:\\Users\\Administrator\\Documents\\GitHub\\geotools4postgis\\src\\main\\java\\iwuang\\test\\bigshp\\MuchBigPolygon.shp");

//        String string = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},
//        InputStream inputStream = new ByteArrayInputStream(string.getBytes());
//        PostgisUtility.importGeojson(inputStream, vector);

//        PostgisUtility.importShp("D:\\Users\\Administrator\\Documents\\Tencent Files\\917485769\\FileRecv\\shpfiletest（仅用于测试）\\shpfiletest\\Export_Output_TXtest.shp", vector);
//        System.out.println( "Hello World!" );
//        PostgisUtility.clearSW();
//        long sec = new Date().getTime() - date.getTime();
//        System.out.println("耗时："+sec);
   }
}
